package com.bjsdzk.common.excel;

import java.util.List;
import java.util.Map;

/**
 * Created by zouLu on 2017-12-14.
 */

public class ExcelData<T> {
    // 表头
    private Map<Integer, List<ExcelTitleItem>> titleMap;
    //表头处理结果
    private Map<String, Object> titleHandlerMap;

    // 数据
    private List<T> rows;

    // 页签名称
    private String name;

    private EntityHandler<T> entityHandler;

    public ExcelData() {
    }

    public ExcelData(Map<Integer, List<ExcelTitleItem>> titleMap, Object rows, String name, EntityHandler<T> entityHandler) {
        Map<String, Object> tmpMap = (Map<String, Object>) rows;
        this.rows = (List<T>) tmpMap.get("list");
        this.titleHandlerMap = tmpMap;
        Map<String, Object> addMap = entityHandler.addToMapHandler();
        if (entityHandler != null && addMap != null) {
            this.titleHandlerMap.putAll(addMap);
        }
        this.entityHandler = entityHandler;
        this.titleMap = titleMap;
        this.name = name;
    }

    public Map<Integer, List<ExcelTitleItem>> getTitleMap() {
        return titleMap;
    }

    public void setTitleMap(Map<Integer, List<ExcelTitleItem>> titleMap) {
        this.titleMap = titleMap;
    }

    public List<T> getRows() {
        return rows;
    }

    public void setRows(List<T> rows) {
        this.rows = rows;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public EntityHandler<T> getEntityHandler() {
        return entityHandler;
    }

    public void setEntityHandler(EntityHandler<T> entityHandler) {
        this.entityHandler = entityHandler;
    }

    public Map<String, Object> getTitleHandlerMap() {
        return titleHandlerMap;
    }

    public void setTitleHandlerMap(Map<String, Object> titleHandlerMap) {
        this.titleHandlerMap = titleHandlerMap;
    }

}

